<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc.jsp"></jsp:include>
<meta http-equiv="X-UA-Compatible" content="edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>投票统计</title>
	<script type="text/javascript">
	var dataGrid;
	$(function() {
	
	
		dataGrid = $('#dataGrid').datagrid({
			url : '${ctx}' + '/voter/dataGrid',
			striped : true,
			rownumbers : true,
			pagination : true,
			singleSelect : true,
			idField : 'id',
			sortName : 'createdatetime',
			sortOrder : 'asc',
			pageSize : 50,
			pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
			frozenColumns : [ [ {
				width : '100',
				title : '标题',
				field : 'title',
				sortable : true
			}, {
				width : '280',
				title : '内容',
				field : 'content',
				sortable : true
			},{
				width : '100',
				title : '开始时间',
				field : 'starttime'
			},{
				width : '100',
				title : '结束时间',
				field : 'endtime'
			}] ],
			columns : [ [ {
				width : '180',
				title : '创建时间',
				field : 'createdate',
				sortable : true
			},  {
				width : '100',
				title : '投票类别',
				field : 'type',
				sortable : true,
				formatter : function(value, row, index) {
					switch (value) {
					case 1:
						return '一人一票';
					case 2:
						return '一人多票';
					}
				}
			}, {
				width : '150',
				title : '候选人',
				field : 'candidate',
				hidden:true
			}, {
				width : '280',
				title : '投票人',
				field : 'voter',
				hidden:true
			}, {
				field : 'action',
				title : '操作',
				width : 100,
				formatter : function(value, row, index) {
					var str = '';
						str += $.formatString('<a href="javascript:void(0)" onclick="openFun(\'{0}\');" >查看</a>', row.id);
					return str;
				}
			}] ]
		});
	});
	
	function openFun(id) {
		parent.$.modalDialog({
			title : '投票统计',
			fit:true,
			href : '${ctx}/voter/countVoter?id='+id,
			buttons : [ {
				text : '关闭',
				handler : function() {
					parent.$.modalDialog.handler.dialog('close');
				}
			} ]
		});
	}
</script>	
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',fit:true,border:false" title="投票列表">
		<table id="dataGrid" data-options="fit:true,border:false"></table>
	</div>
</body>
</html>